Skip to content

fix(nextjs): Don't run webpack plugin on non-prod Vercel deployments #5603

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

lobsterkatie
Copy link
Member

@lobsterkatie lobsterkatie commented Aug 18, 2022

When someone adds our Vercel integration, it only adds sentry-cli-relevant environment variables to production deployments. This can cause non-production deployments to fail, because when the webpack loader tries to run, it doesn't find the information it needs. That said, there's a reason we only set the env variables for prod - we really shouldn't be creating releases or uploading sourcemaps for dev or preview deployments in any case.

This adds an environment check for vercel deployments (using the VERCEL_ENV env variable), and only enables the webpack plugin if the environment is production. To give users a way to override this, setting disableClientWebpackPlugin or disableServerWebpackPlugin to false now takes precedence over other checks, rather than being a no-op. Finally, given that the number of enablement checks is likely to grow, this pulls them into a separate function.

This supersedes getsentry/sentry#37649.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 18, 2022

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 19.4 KB (-0.02% 🔽)
@sentry/browser - ES5 CDN Bundle (minified) 60.06 KB (0%)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 17.98 KB (0%)
@sentry/browser - ES6 CDN Bundle (minified) 52.92 KB (0%)
@sentry/browser - Webpack (gzipped + minified) 19.77 KB (0%)
@sentry/browser - Webpack (minified) 64.31 KB (0%)
@sentry/react - Webpack (gzipped + minified) 19.79 KB (0%)
@sentry/nextjs Client - Webpack (gzipped + minified) 44.72 KB (0%)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 25.91 KB (-0.01% 🔽)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 24.28 KB (-0.01% 🔽)

Copy link
Contributor

@vladanpaunovic vladanpaunovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @lobsterkatie!

Can we make sure that there is some test for this scenario?

Also, once we close this, we should try to understand how this can be solved in non-vercel environments.

@lobsterkatie lobsterkatie force-pushed the kmclb-nextjs-disable-webpack-plugin-for-non-prod-vercel-deployments branch from 39fc0be to 003a6ec Compare August 18, 2022 23:03
Copy link
Contributor

@vladanpaunovic vladanpaunovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good now! Thanks @lobsterkatie!

@lobsterkatie lobsterkatie force-pushed the kmclb-nextjs-disable-webpack-plugin-for-non-prod-vercel-deployments branch 2 times, most recently from 70bdd0c to 6d723d9 Compare August 19, 2022 19:12
@lobsterkatie lobsterkatie force-pushed the kmclb-nextjs-disable-webpack-plugin-for-non-prod-vercel-deployments branch from 6d723d9 to ee43f3c Compare August 19, 2022 19:14
@lobsterkatie lobsterkatie merged commit f411999 into master Aug 19, 2022
@lobsterkatie lobsterkatie deleted the kmclb-nextjs-disable-webpack-plugin-for-non-prod-vercel-deployments branch August 19, 2022 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants